<?php 
$length = isset($_COOKIE['paginationLength'])?$_COOKIE['paginationLength']:10;
if ($_POST && isset($_POST['paginationLength'])){
    setcookie('paginationLength',$_POST['paginationLength']);
    $length = $_POST['paginationLength'];
}
if ($_POST && isset($_POST['paginationPage'])){
    header("Location:".$page->url((int)$_POST['paginationPage']));
    exit;
}
?>

<div id="pager">

	<form action="" method="post" id="paginationForm1" style="display:inline">
	<?php if ($first_page !== FALSE): ?>
	<a href="<?php echo $page->url($first_page) ?>" rel="first">首页</a>
	<?php else: ?>
	<span style="color:#CCCCCC;display:inline-block;padding:3px">首页</span>
	<?php endif ?>
	
	<?php if ($previous_page !== FALSE): ?>
	<a href="<?php echo $page->url($previous_page)?>"><img src="/i/icons/arrow_left.gif" width="16" height="16" /></a>
	<?php endif; ?>	
	
	第<input size="1" value="<?php echo $current_page?>" type="text" name="paginationPage" />页
	
	<?php if ($next_page !== FALSE): ?>
	<a href="<?php echo $page->url($next_page)?>"><img src="/i/icons/arrow_right.gif" width="16" height="16" /></a>
	<?php endif; ?>

	<?php if ($last_page !== FALSE): ?>
	<a href="<?php echo $page->url($last_page) ?>" rel="last">尾页</a>
	<?php else: ?>
	<span style="color:#CCCCCC;display:inline-block;padding:3px">尾页</span>
	<?php endif ?>
	</form>
	
	<form action="" method="post" id="paginationForm2" style="display:inline">
	总共 <?php echo $total_pages?>&nbsp;页&nbsp;|&nbsp;每页
	<?php echo Form::select('paginationLength',array('5'=>5,'10'=>10,'20'=>20,'40'=>40,'80'=>80),$length,array('id'=>'paginationSelect'))?>
	项 | 总共 <strong><?php echo $total_items?></strong> 项
	</form>
	
</div>

<script type="text/javascript">
<!--
document.getElementById('paginationSelect').onchange = function(){
	document.getElementById('paginationForm2').submit();
};
//-->
</script>